package com.yc.oop5;

public class Test3 {
	public static void main(String[] args) {
//		Son s = new Son();
//		s.makeMoney();
		
		//在java里面,如果有继承的关系的前提下,我们可以这样写
		//父类的引用指向子类的对象 ->  引用转型
		Father f = new Son();
		f.makeMoney();
		f.sleep();
//		f.eat();
		System.out.println( f.age ); 
//		f.name = "";
	}
}

class Father{
	public int age = 40;
	public String gender;
	
	public void makeMoney() {
		System.out.println("务农赚钱");
	}
	
	public void sleep() {
		
	}
}

class Son extends Father{
	public int age = 20;
	public String name;
	
	//子类重写了父类的方法
	public void makeMoney() {
		System.out.println("敲代码赚钱");
	}
	
	public void eat() {
		
	}
}